FROM node:22.2.0-slim AS build-stage
RUN npm config set registry https://registry.npmmirror.com --global

WORKDIR /
COPY . .
RUN bash start-nginx.sh
RUN yarn
RUN yarn build:h5

# production stage
FROM nginx:stable AS production-stage

COPY --from=build-stage /dist/build/h5 /usr/share/nginx/html/h5
COPY ./nginx.conf /etc/nginx/nginx.conf
EXPOSE 80

CMD ["nginx", "-g", "daemon off;"]